<template>
  <div class="song">
    <div class="song_top">
      <p>热门推荐</p>
      <a href="javascript:;"
        @click="go_sort">歌单广场
        <span class="iconfont icon-xiangzuo11"></span>
      </a>
    </div>
    <ul class="song_sort">
      <li
        v-for="(index, id) in h_special.list"
        :key="index.id"
        @mouseenter="en_li(index.specialid)"
        @mouseleave="le_li"
        @click="
            go_songList(
              index.specialid,
              index.imgurl,
              index.specialname,
              index.intro
            )
          "
      >
        <div class="show" :class="{ block: spe == index.specialid }">
          <span class="iconfont icon-24gl-play"></span>
        </div>
        <img
          v-lazy="index.imgurl"
          alt=""
          @mouseenter="en_img(index.specialid)"
        />
        <a
          href="#"
          @mouseenter="en_p(index.specialid)"
          @mouseleave="le_p"
          :class="{ color: p_c == index.specialid }"
          >{{ index.specialname }}</a
        >
      </li>
    </ul>
  </div>
</template>

<script>
import { mapState,mapGetters } from "vuex";
export default {
  data() {
    return {
      spe: 0,
      p_c: 0,
    };
  },
  mounted() {
    this.getdata();
  },
  methods: {
    async getdata() {
      this.$store.dispatch("req_h_special");
    },
    //页面效果
    en_li(index) {
      this.spe = index;
    },
    le_li() {
      this.spe = 0;
    },
    en_img(index) {
      this.spe = index;
    },
    en_p(index) {
      this.p_c = index;
      this.spe = 0;
    },
    le_p() {
      this.p_c = 0;
    },
    //去往歌手列表
    go_songList(index, a, b, c) {
      this.$router.push({
        name: "album_list",
        query: {
          special: index,
          img: a,
          name: b,
          time: c,
        },
      });
    },
    //跳往分类详情
    go_sort(){
      this.$router.push({
        name:"special",
        query:{special:1}
      })
    }
  },
  computed: {
    ...mapState({
      h_special: (state) => state.special.h_special,
    }),
  },
};
</script>

<style lang="less">
.song {
  .song_top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    a {
      color: #858585;
      display: block;
      text-align: center;
      flex: 1;
    }
    p {
      flex: 9;
      font-size: 30px;
    }
  }

  .song_sort {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    li {
      position: relative;
      width: 180px;
      height: 220px;
      margin-bottom: 10px;
      img {
        height: 180px;
        width: 180px;
        border-radius: 10px;
        margin-bottom: 5px;
        cursor: pointer;
      }
      a {
        display: inline-block;
        width: 100%;
        height: 30px;
        font-size: 12px;
        color: #000;
      }
    }
    //flex最后一列对齐问题
    li:last-child:nth-child(5n-1) {
      margin-right: 205px;
    }
    li:last-child:nth-child(5n-2) {
      margin-right: 410px;
    }
    li:last-child:nth-child(5n-3) {
      margin-right: 615px;
    }
    .show {
      display: none;
      position: absolute;
      width: 180px;
      height: 180px;
      border-radius: 10px;
      top: 0;
      background-color: #000;
      opacity: 0.5;
      .icon-24gl-play {
        color: #fff;
        position: absolute;
        top: 70px;
        left: 70px;
        width: 40px;
        height: 40px;
        font-size: 40px;
      }
    }
    .block {
      display: block;
    }
    .color {
      color: #00a9ff;
    }
  }
}
</style>